<script setup>
import {reactive, ref} from "vue";
import {useRouter} from "vue-router";

/*let uesrname = ref("")
let password = ref("")*/
let router = useRouter()
let user = reactive({
  username: "",
  password: ""
})
let login = () => {
  if (user.username == admin && user.password == 123456) {
    localStorage.setItem("username", user.username)
    alert("登录成功")
    router.push("/")
  } else {
    alert("用户名和密码不正确")
  }
}
</script>

<template>
  <div>
    <h1>Login.vue</h1>
    用户名：<input type="text" v-model:="user.password"/><br/>
    密码：<input type="password" v-model:="user.username"/><br/>
    <button @click="login">登录</button>
    <br/>
  </div>
</template>

<style scoped>

</style>